@ var head ={
<title>专业科目</title>
@}; var body={
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'center',border:false" title=""
		style="overflow: hidden;">
		<table id="treeGrid"></table>
	</div>
</div>
<div id="toolbar" style="display: none;">
	<shiro:hasPermission name="/system/res/add">
		<a onclick="addFun();" href="javascript:void(0);"
			class="easyui-linkbutton"
			data-options="plain:true,iconCls:'pencil_add'">添加</a>
	</shiro:hasPermission>
	<a onclick="tgredo(treeGrid);" href="javascript:void(0);"
		class="easyui-linkbutton"
		data-options="plain:true,iconCls:'resultset_next'">展开</a> <a
		onclick="tgundo(treeGrid);" href="javascript:void(0);"
		class="easyui-linkbutton"
		data-options="plain:true,iconCls:'resultset_previous'">折叠</a> <a
		onclick="treeGrid.treegrid('reload');" href="javascript:void(0);"
		class="easyui-linkbutton" data-options="plain:true,iconCls:'transmit'">刷新</a>
</div>
<!--  dialog -->
<div id="dlg" class="easyui-dialog"
	style="width: 540px; height: 350px; padding: 5px 10px" closed="true"
	buttons="#dlg-buttons" data-options="resizable:true,modal:true">

	<div class="easyui-layout" data-options="fit:true,border:false">
		<div data-options="region:'center',border:false" title=""
			style="overflow: hidden;">
			<form id="fm" method="post">
				<input name="zyid_zykm_combobox_edit_zyid" id="zyid_zykm_combobox_edit_zyid" type="hidden" class="span2" value="">
				<input name="pid" id="pid" type="hidden" class="span2" value="">
				<table class="table table-hover table-condensed">
					<tr>
						<th>专业</th>
						<td><input name="zyid" id="zyid_zykm_combobox_edit"
							class="easyui-validatebox span2"
							data-options="width:140,height:29" /></td>
						<th>科目</th>
						<td><input name="kmid" id="kmid_zykm_combobox_edit"
							class="easyui-validatebox span2"
							data-options="width:140,height:29" /></td>
					</tr>
					<tr>
						<th>学分</th>
						<td><input name="kmxf" type="text" placeholder="请输入资源名称"
							class="easyui-validatebox span2" data-options="required:true"
							value=""></td>
						<th>科目类型</th>
						<td><select name="kmlx"
							class="easyui-combobox easyui-validatebox"
							data-options="required:true,width:140,height:29,editable:false,panelHeight:'auto'">
								<option value="1" selected="selected">必考</option>
								<option value="2">选考</option>
								<option value="3">实践</option>
								<option value="4">加考</option>
						</select></td>
					</tr>

				</table>
			</form>
		</div>
	</div>
</div>
<div id="dlg-buttons">
	<a href="javascript:void(0)" class="easyui-linkbutton"
		onclick="submit()">确定</a> <a href="javascript:void(0)"
		class="easyui-linkbutton"
		onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>
</div>
@}; var js ={

<script type="text/javascript">
	//init
	var zyid_zykm_combobox_edit_zyid;
	$("#zyid_zykm_combobox_edit").combogrid(
			{
				panelWidth : 450,
				idField : "zyid",
				textField : "zymc",
				sortName : 'zyid',
				sortOrder : 'desc',
				pagination : true,
				pageSize : 10,

				url : PATH + '/business/zykm/select',
				keyHandler : {
					enter : function() {
						$("#zyid_zykm_combobox_edit").combogrid(
								{
									queryParams : {

										'zymc' : $("#zyid_zykm_combobox_edit")
												.combogrid('getText')

									}
								});
					}
				},
				columns : [ [ {
					field : 'zyid',
					title : '代码',
					width : 100
				}, {
					field : 'zymc',
					title : '名称',
					width : 250
				}

				] ],
				onSelect : function(index,record) { //选中处理
					
				$("#pid").val(record.id);
				zyid_zykm_combobox_edit_zyid=record.zyid;
				$("#kmid_zykm_combobox_edit").combogrid(
						{
							queryParams : {
								 'zyid':zyid_zykm_combobox_edit_zyid
							}
						});
				//$('#kmid_zykm_combobox_edit').combogrid('grid').datagrid("reload");
				//$("#kmid_zykm_combobox_edit").combogrid('reload');
				}
			});
	$("#kmid_zykm_combobox_edit").combogrid(
			{
				panelWidth : 450,
				idField : "kmDm",
				textField : "kmMc",
				sortName : 'kmDm',
				sortOrder : 'desc',
				pagination : true,
				pageSize : 10,
				queryParams : {'zyid':zyid_zykm_combobox_edit_zyid},
				url : PATH + '/business/zykm/selectKemu',
				keyHandler : {
					enter : function() {
						$("#kmid_zykm_combobox_edit").combogrid(
								{
									queryParams : {
										 'zyid':zyid_zykm_combobox_edit_zyid,
										'kmMc' : $("#kmid_zykm_combobox_edit")
												.combogrid('getText')

									}
								});
					}
				},
				columns : [ [ {
					field : 'kmDm',
					title : '代码',
					width : 100
				}, {
					field : 'kmMc',
					title : '名称',
					width : 250
				}

				] ]
			});
	$('#iconCls')
			.combobox(
					{
						data : $.iconData,
						formatter : function(v) {
							return $
									.formatString(
											'<span class="{0}" style="display:inline-block;vertical-align:middle;width:16px;height:16px;"></span>{1}',
											v.value, v.value);
						}
					});
	var treeGrid = $('#treeGrid')
			.treegrid(
					{
						url : '${CONTEXT_PATH}/business/zykm/list',
						idField : 'id',
						treeField : 'zymc',
						parentField : 'pid',
						fit : true,
						fitColumns : false,
						border : false,
						frozenColumns : [ [ {
							title : '编号',
							field : 'id',
							width : 150,
							hidden : true
						} ] ],
						columns : [ [
								{
									field : 'zymc',
									title : '专业名称',
									width : 300
								},
								{
									field : 'zyid',
									title : '专业代码',
									width : 100
								},
								{
									field : 'kmid',
									title : '科目代码',
									width : 150
									
								},
								{
									field : 'kmmc',
									title : '科目名称',
									width : 150
								},
								{
									field : 'kmlxMc',
									title : '科目类型',
									width : 80
								},
								{
									field : 'kmxf',
									title : '学分',
									width : 80

								},
								{
									field : 'action',
									title : '操作',
									width : 50,
									formatter : function(value, row, index) {
										var str = '';
										str += $
												.formatString(
														'<shiro:hasPermission name="/business/zykm/delete"><img onclick="deleteFun(\'{0}\');" src="{1}" title="删除"/> </shiro:hasPermission>',
														row.id,
														'${CONTEXT_PATH}/static/js/ext/style/images/extjs_icons/cancel.png');
										return str;
									}
								} ] ],
						toolbar : '#toolbar',
						onContextMenu : function(e, row) {
							e.preventDefault();
							$(this).treegrid('unselectAll');
							$(this).treegrid('select', row.id);
							$('#menu').menu('show', {
								left : e.pageX,
								top : e.pageY
							});
						},
						onLoadSuccess : function() {
							parent.$.messager.progress('close');
							$(this).treegrid('tooltip');
						}
					});

	function deleteFun(id) {
		if (id != undefined)
			treeGrid.treegrid('select', id);
		var node = treeGrid.treegrid('getSelected');
		if (node) {
			parent.$.messager.confirm('询问', '您是否要删除当前资源？', function(b) {
				if (b) {
					parent.$.messager.progress({
						title : '提示',
						text : '数据处理中，请稍后....'
					});
					$.post('${CONTEXT_PATH}/business/zykm/delete', {
						id : node.id
					}, function(result) {
						if (result.success) {
							treeGrid.treegrid('reload');
							$("#zyid_zykm_combobox_edit").combogrid('grid').datagrid('reload');  
						}
						parent.$.messager.progress('close');
					}, 'JSON');
				}
			});
		}
	}

	function addFun() {
		$('#fm').form('clear');
		showDialog('#dlg', '添加资源');
		url = '${CONTEXT_PATH}/business/zykm/add';

	}

	function submit() {
		$('#fm').form('submit', {
			url : url,
			success : function(result) {
				result = $.parseJSON(result);
				if (result.success) {
					$('#dlg').dialog('close');
					treeGrid.treegrid('reload');
				} else {
					$.messager.alert('提示', result.data);
				}
			}
		}); 
	}
</script>

@}; include("../layout/_layout.html",{head:head,body:body,js:js}){}


